Untitled
unknown
plain_text
2 years ago
1.4 kB
6
Indexable
#START=THERMOMETER.EXE# TITLE IOANNIS STAMOU DEDOMENA SEGMENT MENU DB "ENTER A DECIMAL NUMBER (0-255):$" MSG_OFF DB "max temp reached, turning off heater", 10, 13, "$" MSG_ON DB "min temp reached, turning on heater", 10, 13, "$" DEDOMENA ENDS KWDIKAS SEGMENT ARXH: MOV AX, DEDOMENA MOV DS, AX LEA DX, MENU MOV AH, 09h INT 21H ; Read a decimal number from the user MOV AH, 01h INT 21H ; Convert ASCII to integer SUB AL, '0' MOV AH, 0 MOV CX, 10 MUL CX MOV CX, 0 ADD AX, CX ; Print the entered decimal number MOV CX, AX ; Save the number for later MOV AH, 02h INT 21H ; Print the number in binary form MOV CX, 8 ; Number of bits for an 8-bit binary representation MOV DX, 1 ; Initial mask for the leftmost bit PRINT_BINARY_LOOP: ; Check the leftmost bit and print '0' or '1' TEST AX, DX JZ PRINT_BINARY_ZERO MOV DL, '1' JMP PRINT_BINARY_PRINT PRINT_BINARY_ZERO: MOV DL, '0' PRINT_BINARY_PRINT: ; Print the binary digit MOV AH, 02h INT 21H ; Shift the mask to the right SHR DX, 1 ; Repeat for all bits LOOP PRINT_BINARY_LOOP ; Print a newline MOV DL, 10 MOV AH, 02h INT 21H ; Rest of your code... ; (Make sure to adjust the registers used as needed) KWDIKAS ENDS SOROS SEGMENT STACK db 265 dup(0) SOROS ENDS END ARXH
Editor is loading...
Leave a Comment