Write an HLA Assembly program that prompts for an int8 value toinspect and then prints it in binary format. For example, herewould be the program output for various entered valuesGimme a decimal value to print: 1515 is 0000_1111Gimme a decimal value to print: 77 is 0000_0111(Hint: There is no standard output that prints in binary output, soyou need to do this yourself. In order to accomplish this, you needto move a bit at time into the carry flag and print 0 or 1,depending on what you find in the Carry bit. Shift and repeat thisprocedure 8 times and you are done! Eventually, we will learn howto loop, which would make this task much less terrible.)
(Second Hint:LAHF pushes the Carry Bit and all the other flagsout of the EFLAGS register and into AH. As an Assembly programmer,you have the power to mask out all the bits but the one you areinterested in by using either AND or OR.)
Programmer's Reference to HLA Assembly Language Typical Program Structure program progID; #include( "stdlib.hhf" ); static end progID; Assembly Language Instructions Description MOV Instruction Syntax mov( ADD SUB SHL SHR variable declarations SAR begin progID; statements ROL source, dest); add( source, dest); sub( source, dest); shl( count, dest); shr ( count, dest); sar ( count, est ); rol( count, dest); dest= source; dest += source; dest -= source; shuffles left a total of count bits in dest operand; sets carry when count=1 shuffles right a total of count bits in dest operand; sets carry when count=1 shuffles right a total of count bits in dest operand; sets carry when count=1; leaves H.O. bit unchanged rotates left a total of count bits Available Datatypes int8 int16 int32 boolean Available 1/0 Routines stdout.put stdout.puti8 stdout.puti16 stdout.puti32 stdout.putb stdout.putw stdout.putd stdout.newln stdin.get stdin.geti8 stdin.geti16 stdin.geti32 stdin.getb stdin.getw stdin.getd
ROR NOT AND OR XOR LAHF ror ( count, dest); and ( source, dest); or ( source, dest); xor ( source, dest); in dest operand; sets carry when count=1 inverts the not( dest bits of the )); dest lahf(); count=1 rotates right a total of count bits in dest operand; sets carry when operand bitwise logical AND; result placed in dest operand bitwise inclusive OR; result placed in dest operand bitwise exclusive OR; result placed in dest operand pushes the lower 8 bits of EFLAGS register into AH
Write an HLA Assembly program that prompts for an int8 value to inspect and then prints it in binary format. For example
-
- Site Admin
- Posts: 899566
- Joined: Mon Aug 02, 2021 8:13 am